package licode.unisop.single.platform.infrastructure.assembler;

import cn.hutool.json.JSONUtil;
import licode.unisop.provider.vo.SiProps;
import org.springframework.stereotype.Component;

@Component
public class DataTypeConverter {
    public String propsToString(SiProps props) {
        if (null == props) {
            return null;
        } else {
            return JSONUtil.toJsonStr(props);
        }
    }

    public SiProps stringToProps(String props) {
        if (null == props) {
            return new SiProps();
        } else {
            try {
                return JSONUtil.toBean(props, SiProps.class);
            } catch (Exception ignore) {
                return new SiProps();
            }
        }
    }
}
